home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / tptc17tc.zip / SUBRANGE.PAS < prev    next >
Pascal/Delphi Source File  |  1988-03-25  |  1KB  |  37 lines

  1.  
  2. (*
  3.  * Example of character and enumeration subrange types
  4.  *)
  5.  
  6. program Scaler_Operations;
  7.  
  8. type 
  9.      Days = (Mon,Tue,Wed,Thu,Fri,Sat,Sun);
  10.      Work = Mon..Fri;
  11.      Rest = Sat..Sun;
  12.  
  13. var  
  14.      Day      : Days; (* This is any day of the week *)
  15.      Workday  : Work; (* These are the the working days *)
  16.      Weekend  : Rest; (* The two weekend days only *)
  17.      Index    : 1..12;
  18.      Alphabet : 'a'..'z';
  19.      Start    : 'a'..'e';
  20.  
  21. begin  (* main program *)
  22.    Workday := Tue;
  23.    Weekend := Sat;
  24.    Day := Workday;
  25.    Day := Weekend;
  26.    Index := 3+2*2;
  27.    Start := 'd';
  28.    Alphabet := Start;
  29.                              (* since Alphabet is "d"    *)
  30.    Start := Succ(Alphabet);  (* Start will be 'e'        *)
  31.    Start := Pred(Alphabet);  (* Start will be 'c'        *)
  32.    Day := Wed;
  33.    Day := Succ(Day);  (* Day will now be 'Thu' *)
  34.    Day := Succ(Day);  (* Day will now be 'Fri' *)
  35.    Index := Ord(Day); (* Index will be 4 (Fri = 4) *)
  36. end. (* of main program *)
  37.